package cn.com.nes.site.entity.em.crm.saleorder;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 系统单状态 枚举
 *  值域对应 t_param 表 param_type = 305
 */
public enum SaleMasterStatusEnum {

    USER_CONFIRMED(0, "用户待确认"),
    PASS(1, "通过"),
    ABANDONED(2, "作废"),
    ;

    private Integer key;

    private String value;

    SaleMasterStatusEnum(Integer key, String value) {
        this.key = key;
        this.value = value;
    }

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static SaleMasterStatusEnum getEnum(String key) {
        Map<String, SaleMasterStatusEnum> map = new HashMap<>();
        for (SaleMasterStatusEnum saleOrderStatusEnum : values()) {
            map.put(String.valueOf(saleOrderStatusEnum.getKey()), saleOrderStatusEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的系统单状态");
        }
        return map.get(String.valueOf(key));
    }
}
